<?php

namespace app\index\controller;

use app\index\model\OrderModel;
use think\Controller;
use think\Request;

class OrderController extends Controller
{
    public function index()
    {
        // echo 111;die;
        $data = model('OrderModel') ->search_mess();
       // var_dump($data);die;

        for($k=0; $k<count($data); $k++){
            $data[$k]['goods_Mprice'] = $data[$k]['count']*$data[$k]['price'];
        }
        
        $data[0]['Allprice'] = 0;
        for($i=0; $i<(count($data)); $i++){
            $data[0]['Allprice'] += $data[$i]['goods_Mprice'];
        }
       // var_dump($data);die;
        return view('order/index',[
            'mess' => $data
        ]);
    }

    public function sure()
    {
        $data = model('OrderModel') ->insert_mess();
        if($data){
            return $this->success('您已成功下单~~请稍等...','index/MycenterController/index');
        }else{
            return $this->error('很抱歉,目前系统繁忙..请稍后');
        }
    }
}